//
//  MQSmallDetailViewsOfFind.m
//  MinDyNews
//
//  Created by ZMQ on 16/7/23.
//  Copyright © 2016年 MQ. All rights reserved.
//

#import "MQSmallDetailViewsOfFind.h"
#import "MQSamllModelOfFind.h"

@interface MQSmallDetailViewsOfFind ()




@end

@implementation MQSmallDetailViewsOfFind




-(instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        [self configSubViews];
        
    }
    return self;
}

-(void)configSubViews{
    
    self.imageViewOfcover = [[UIImageView alloc]init];
    [self addSubview:_imageViewOfcover];
    
    [self.imageViewOfcover mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self);
        make.left.equalTo(self);
        make.right.equalTo(self);
        make.height.offset(280);
    }];
    self.imageViewOfcover.userInteractionEnabled = YES;//图片交互
    
    //阴影图片的控件
    self.imageViewOfShadow = [[UIImageView alloc]init];
    [self addSubview:_imageViewOfShadow];

    /**图片翻转180度*/
    //    self.imageViewOfShadow.transform = CGAffineTransformRotate(self.transform, M_PI);
    self.imageViewOfShadow.frame = CGRectMake(0, 280, WIDTH, HEIGHT-280);
    
    /**虚化效果*/
    UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
    UIVisualEffectView *effectview = [[UIVisualEffectView alloc] initWithEffect:blur];
    effectview.frame = self.imageViewOfShadow.bounds;
    [self.imageViewOfShadow addSubview:effectview];
    effectview.alpha = 1;
    
    
    /**大标题*/
    self.labelOftitle = [[UILabel alloc]init];
    [self.imageViewOfShadow addSubview:_labelOftitle];
    
    self.labelOftitle.font = [UIFont systemFontOfSize:13 weight:1];
    self.labelOftitle.textColor = [UIColor whiteColor];
    [self.labelOftitle mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.imageViewOfShadow).with.offset(10);
        make.left.equalTo(self.imageViewOfShadow).with.offset(10);
        make.right.equalTo(self.imageViewOfShadow).with.offset(-10);
        make.height.offset(20);
        
    }];
    
    
    
    self.labelOfcategory = [[UILabel alloc]init];
    [self.imageViewOfShadow addSubview:_labelOfcategory];
  
    self.labelOfcategory.font = [UIFont systemFontOfSize:11];
    self.labelOfcategory.textColor = [UIColor whiteColor];
    
    [self.labelOfcategory mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.labelOftitle.mas_bottom).with.offset(10);
        make.left.equalTo(self.imageViewOfShadow).with.offset(10);
        make.width.offset(35);
        make.height.offset(20);
        
    }];
    
    
    
    self.labelOfduration = [[UILabel alloc]init];
    [self.imageViewOfShadow addSubview:_labelOfduration];
    
    self.labelOfduration.font = [UIFont systemFontOfSize:11];
    self.labelOfduration.textColor = [UIColor whiteColor];
    [self.labelOfduration mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.labelOftitle.mas_bottom).with.offset(10);
        make.left.equalTo(self.labelOfcategory.mas_right);
        make.width.offset(60);
        make.height.offset(20);
        
    }];
    
    
    self.viewOfLine = [[UIView alloc]init];
    [self.imageViewOfShadow addSubview:_viewOfLine];
    
    self.viewOfLine.backgroundColor = [UIColor grayColor];
    [self.viewOfLine mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.labelOfcategory.mas_bottom).with.offset(15);
        make.left.equalTo(self.imageViewOfShadow).with.offset(10);
        make.right.equalTo(self.imageViewOfShadow);
        make.height.offset(1);
        
    }];
    
    /**最下一排的分享，评论，喜欢*/
    
    self.labelOfShare = [[UILabel alloc]init];
    [self.imageViewOfShadow addSubview:_labelOfShare];
    
    self.labelOfShare.font= [UIFont systemFontOfSize:11];
    self.labelOfShare.textColor = [UIColor whiteColor];
    [self.labelOfShare mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.equalTo(self.imageViewOfShadow).with.offset(-30);
        make.centerX.equalTo(self.imageViewOfShadow);
        make.width.offset(60);
        make.height.offset(20);
        
    }];
    
    
    self.labelOfLove = [[UILabel alloc]init];
    [self.imageViewOfShadow addSubview:_labelOfLove];
    
    self.labelOfLove.font= [UIFont systemFontOfSize:11];
    self.labelOfLove.textColor = [UIColor whiteColor];
    [self.labelOfLove mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.equalTo(self.imageViewOfShadow).with.offset(-30);
        make.right.equalTo(self.labelOfShare.mas_left).with.offset(-40);
        make.width.offset(60);
        make.height.offset(20);
        
    }];
    
    self.labelOfComment = [[UILabel alloc]init];
    [self.imageViewOfShadow addSubview:_labelOfComment];
    
    self.labelOfComment.font= [UIFont systemFontOfSize:11];
    self.labelOfComment.textColor = [UIColor whiteColor];
    [self.labelOfComment mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.equalTo(self.imageViewOfShadow).with.offset(-30);
        make.left.equalTo(self.labelOfShare.mas_right).with.offset(40);
        make.width.offset(60);
        make.height.offset(20);
        
    }];
    
    
    
    
    
    /**中间的小标题*/
    self.labelOfSamllTitle = [[UILabel alloc]init];
    [self.imageViewOfShadow addSubview:_labelOfSamllTitle];
    
    
    self.labelOfSamllTitle.numberOfLines = 0;
    self.labelOfSamllTitle.font= [UIFont systemFontOfSize:11];
    self.labelOfSamllTitle.textColor = [UIColor whiteColor];
    self.labelOfSamllTitle.highlighted = YES;
    [self.labelOfSamllTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.viewOfLine.mas_bottom).with.offset(15);
        make.left.equalTo(self.imageViewOfShadow).with.offset(10);
        make.right.equalTo(self.imageViewOfShadow).with.offset(-10);
        make.bottom.equalTo(self.labelOfLove.mas_top).with.offset(-10);
        
    }];
    
    
    
}

-(void)setModelOfSamll:(MQSamllModelOfFind *)modelOfSamll{
    
    _modelOfSamll = modelOfSamll;
        


    
    //图片
    NSURL *url = [NSURL URLWithString:[[modelOfSamll.data objectForKey:@"cover"]objectForKey:@"feed"]];
    [self.imageViewOfcover sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"ZMQ"]];
    
    //阴影图片
    
    [self.imageViewOfShadow sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"ZMQ"]];

    
    //标题
    self.labelOftitle.text = [modelOfSamll.data objectForKey:@"title"];
    
    //创意类型
    
    self.labelOfcategory.text = [NSString stringWithFormat:@"#%@", [modelOfSamll.data objectForKey:@"category"]];
    
    
    //时间
    NSInteger time = [[modelOfSamll.data objectForKey:@"duration"] integerValue];
    NSInteger minute = time / 60;
    NSInteger second = time % 60;
    
    self.labelOfduration.text = [NSString stringWithFormat:@"/   %ld分%ld秒", (long)minute, (long)second] ;
    
    //小标题
    self.labelOfSamllTitle.text = [modelOfSamll.data objectForKey:@"description"];
    
    //喜欢，点击和评论
    
    self.labelOfLove.text =  [NSString stringWithFormat:@"喜欢:%@", [[modelOfSamll.data objectForKey:@"consumption"]objectForKey:@"collectionCount"]];
    self.labelOfShare.text =  [NSString stringWithFormat:@"分享:%@", [[modelOfSamll.data objectForKey:@"consumption"]objectForKey:@"shareCount"]];
    self.labelOfComment.text =  [NSString stringWithFormat:@"评论:%@", [[modelOfSamll.data objectForKey:@"consumption"]objectForKey:@"replyCount"]];
    
    
    
}


@end
